<?php
/**
 * @version		$Id: mod_vavim.php 2011-07-05 vinaora $
 * @package		Vinaora AVIM Keyboard
 * @subpackage	mod_vavim
 * @copyright	Copyright (C) 2007 - 2011 VINAORA. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 * @website		http://vinaora.com
 * @twitter		http://twitter.com/vinaora
 * @facebook	http://facebook.com/vinaora
 *
 * @note		AVIM Javascript (avim.js) - Copyright (C) 2004-2008 Hieu Tran Dang <lt2hieu2004 (at) users (dot) sf (dot) net
 */

// no direct access
defined('_JEXEC') or die;

// Require the base helper class only once
// require_once dirname(__FILE__).DS.'helper.php';


$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx'));

// variable for avim
$style		= $params->get('style');
$method		= $params->get('method');
$ckSpell	= $params->get('ckSpell');
$oldAccent	= $params->get('oldAccent');
$useCookie	= $params->get('useCookie');
$exclude	= $params->get('exclude');

// other variables
$onOff		= $method=="-1"?0:1;

$showControl = ( $style=="float" )?"1":"0";

$css		= JURI::base()."media/mod_vavim/css/avim.css";
$avim		= JURI::base()."media/mod_vavim/js/avim.js";

$avimtag	= '<script type="text/javascript" src="'.$avim.'"></script>';

$avim_config = '
	<script type="text/javascript">
	var AVIMGlobalConfig = {
		method: '.$method.', //Default input method: 0=AUTO, 1=TELEX, 2=VNI, 3=VIQR, 4=VIQR*
		onOff: '.$onOff.', //Starting status: 0=Off, 1=On
		ckSpell: '.$ckSpell.', //Spell Check: 0=Off, 1=On
		oldAccent: '.$oldAccent.', //0: New way (oa`, oe`, uy`), 1: The good old day (o`a, o`e, u`y)
		useCookie: '.$useCookie.', //Cookies: 0=Off, 1=On
		exclude: ["'.$exclude.'"], //IDs of the fields you DON\'T want to let users type Vietnamese in
		showControl: '.$showControl.', //Show control panel: 0=Off, 1=On. If you turn this off, you must write your own control panel.
		controlCSS: "'.$css.'" //Path to avim.css
	};

	//Set to true the methods which you want to be included in the AUTO method
	var AVIMAutoConfig = {
		telex: true,
		vni: true,
		viqr: false,
		viqrStar: false
	};
	</script>';

$document = JFactory::getDocument();
$document->addCustomTag($avim_config);

if ( $style=="float" || $style="hide" ){
	$document->addCustomTag($avimtag);
}
else{
	echo "\n<!-- Begin: Vinaora AVIM Vietnamese Keyboard from http://vinaora.com/ -->\n";
	require JModuleHelper::getLayoutPath('mod_vavim', $style);
	echo "\n<!-- End: Vinaora AVIM Vietnamese Keyboard from http://vinaora.com/ -->\n";
}
